﻿using FarmSmartSleep.Common.Domain;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.Commands.DepartmentCommands
{
    public class DepartTypeSearchHandler : IRequestHandler<DepartTypeSearchCommands, Result>
    {
        private readonly IBaseRepository<DepartmentType> departTypebaseRepository;

        public DepartTypeSearchHandler(IBaseRepository<DepartmentType> departTypebaseRepository)
        {
            this.departTypebaseRepository = departTypebaseRepository;
        }
        /// <summary>
        /// 部门类型
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Result> Handle(DepartTypeSearchCommands request, CancellationToken cancellationToken)
        {
            var result= new Result() { Code=(int)CodeEnum.search};
            var list= departTypebaseRepository.GetAll().ToList();
            result.Data = list;
            return result;
        }
    }
}
